#include <stdio.h>
#include "XTime.h"

// 获取当前时间的年、月、日
// year: 年指针
// month: 月指针
// day: 日指针
void NowYMD(int *year, int *month, int *day) {
    time_t t = time(NULL);
    struct tm *tm = localtime(&t);
    *year = tm->tm_year + 1900;
    *month = tm->tm_mon + 1;
    *day = tm->tm_mday;
}

// 获取当前时间的时、分、秒
// hour: 时指针
// minute: 分指针
// second: 秒指针
void NowHMS(int *hour, int *minute, int *second) {
    time_t t = time(NULL);
    struct tm *tm = localtime(&t);
    *hour = tm->tm_hour;
    *minute = tm->tm_min;
    *second = tm->tm_sec;
}

// 获取当前时间的时间戳，单位：秒
// timestamp: 时间戳指针
void NowTimestamp(long *tsSecond) {
    time_t t = time(NULL);
    *tsSecond = t;
}
